package com.sc.nft.task;

import com.sc.nft.entity.MallActivity;
import com.sc.nft.service.MallActivityService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
@Slf4j
public class MallActivityTask {

    private final MallActivityService mallActivityService;
    
    /**
     * 更新已结束的活动
     */
    @XxlJob("updateFinishedActivities")
    public void updateFinishedActivities() {
        List<MallActivity> mallActivityList = mallActivityService.queryFinishedActivities();
        for (MallActivity mallActivity : mallActivityList) {
            mallActivityService.offShelf(mallActivity.getId());
        }
    }
}
